
import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_deer/login/iview/update_password_by_username_iview.dart';
import 'package:flutter_deer/login/models/register_user_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/net.dart';
import 'package:flutter_deer/res/constant.dart';
import 'package:flutter_deer/util/other_utils.dart';

class UpdatePasswordByUsernamePagePresenter extends BasePagePresenter<UpdatePasswordByUsernameIMvpView> {

  @override
  void initState() {

  }

  Future<dynamic> updatePassword(String oldPassword,String newPassword) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final UpdatePasswordByUsernameEntity updatePasswordByUsernameEntity = UpdatePasswordByUsernameEntity(username:SpUtil.getString(Constant.phone),oldPassword: oldPassword.nullSafe,newPassword: newPassword.nullSafe);
      requestNetwork<OperatorBaseEntity>(Method.put,
          url: HttpApi.updatePassword,
          params: updatePasswordByUsernameEntity.toJson(),
          onSuccess: (data) {
            view.updatePasswordResult(data!.data);
          },
          onError: (code,msg){

          }
      );
    });

  }

}
